<?php
	//timer pengecekan load page...
	include("timer.php");
	$_start_timer = get_microtime();

	require_once("protect1.php"); 
	require_once("connect.php");
	require_once("settings.php");

	// $pilih=mysql_select_db("uwika_krs",$conn);
	$pdo->query("USE uwika_krs");
	
	//ganti dengan yg otomatis 
	$_recno = $_GET["recno"];
    $_kodemk = $_GET["kodemk"];
	
	//$_sesi = $_GET["sesi"];
	//$_periode = $_GET["periode"];
	$_periode= $_global_settings['tahun_ajaran']->value;
	$_sesi = $_global_settings['semester']->value;
	
	//protect2 
	//cheking semester.. biar gk aneh2 mbukak.. prevent from sql injection
	//JANGAN dihapus, karna ini skaligus Query data2 Matakuliah (digabung dengan protect2)
	$sql = "SELECT semester, dosen, pagu, keterangan, mk.nama, mk.sks, penawaran.kodemk, penawaran.hari, penawaran.mulaipukul, penawaran.selesaipukul 
			FROM penawaran, mk where penawaran.kodemk = :kodemk and sesi = :sesi 
			AND periode = :periode and penawaran.kodemk = mk.kodemk
			AND jurusan = :reg_jurusan
			AND recno = :recno
			";
	$stmt = $pdo->prepare($sql);
	$stmt->execute(array(':recno' => $_recno
							,':kodemk' => $_kodemk
							,':sesi' => $_sesi
							,':periode' => $_periode
							,':reg_jurusan' => $reg_jurusan));
	/*
	$stmt->execute(array(':kodemk' => $_kodemk
							,':sesi' => $_sesi
							,':periode' => $_periode
							,':reg_jurusan' => $reg_jurusan));
	*/
	$_data = $stmt->fetch(PDO::FETCH_OBJ);

	if(empty($_data->kodemk)){
		//manual input.. g onok matakuliah coy...
		$host  = $_SERVER['HTTP_HOST'];
		$uri   = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
		$extra = 'studentpage.php';
		header("Location: http://$host$uri/$extra");
		?>
			Something error happen... call administrator
			<meta http-equiv="refresh" content="0; url=<?php echo $extra; ?>">
			Klik <a href="<?php echo $extra; ?>">disini</a> apabila browser anda berhenti berjalan ...
		<?php
		exit;
	}
?>
<STYLE type=text/css>.blank {
	FONT-SIZE: 0px; WIDTH: 0px; HEIGHT: 0px
}
TD {
	FONT-SIZE: 12px; COLOR: #000000; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif
}
INPUT {
	FONT-SIZE: 12px; COLOR: #000000; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif
}
.present {
	FONT-WEIGHT: bold; BACKGROUND-COLOR: #dee5ec
}
.h1 {
	FONT-WEIGHT: bold; FONT-SIZE: 12px; COLOR: #ffffff
}
.d1 {
	COLOR: #c0c0c0
}
.link {
	FONT-WEIGHT: bold; FONT-SIZE: 12px; CURSOR: hand; COLOR: #ffffff; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; TEXT-DECORATION: none
}
.footer {
	FONT-WEIGHT: normal; FONT-SIZE: 10px; COLOR: #000000; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; TEXT-DECORATION: none
}
.footer1 {
	FONT-WEIGHT: bold; FONT-SIZE: 10px; BACKGROUND-IMAGE: url(chat/images/menu_b.gif); CURSOR: default; COLOR: #000000; BORDER-BOTTOM: 0px
}
.header {
	FONT-WEIGHT: bold; FONT-SIZE: 10px; BACKGROUND-IMAGE: url(chat/images/menu_h.gif); CURSOR: default; COLOR: #000000; BORDER-BOTTOM: 0px
}
.textcol {
	FONT-SIZE: 12px; COLOR: #2378d5; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif
}
</STYLE>


<style type="text/css">
<!--
body,td,th {
	color: #FFFFFF;
	font-family: Arial, Helvetica, sans-serif;
	font-size: 11pt;
}
body {
	background-color: #001E8C;
	background-image: url(bg.jpg);
	background-repeat: repeat;
}
a:link {
	color: #FFFFFF;
	text-decoration: none;
}
a:visited {
	color: #CCCCCC;
	text-decoration: none;
}
a:hover {
	color: #001E8B;
	text-decoration: underline;
}
a:active {
	color: #001F8A;
	text-decoration: none;
}
-->
</style>
<title>:: HOME ::</title><table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td bgcolor="7e96dc">&nbsp;</td>
  </tr>
  <tr>
    <td><img src="images/bannerAtas.jpg" alt="image" width="780" height="200" /></td>
  </tr>
  <tr>
    <td bgcolor="3a5db1">
		<BR>
		<table width="88%" border="0">
		<tr><td width="5%"></td>
		<td width="15%">Kode Mata Kuliah</td><td width="1%">:</td><td><?php echo $_data->kodemk; ?></td></tr>
		<tr><td width="5%"></td>
		<td>Nama Mata Kuliah</td><td>:</td><td><?php echo $_data->nama; ?></td></tr>
		<tr><td width="5%"></td>
		<td>Jumlah SKS</td><td>:</td><td><?php echo $_data->sks; ?></td></tr>
		<tr><td width="5%"></td>
		<td>Keterangan</td><td>:</td><td><?php echo $_data->keterangan; ?></td></tr>
		<tr><td width="5%"></td>
		<td>Semester</td><td>:</td><td><?php echo $_data->semester; ?></td></tr>
		<tr><td width="5%"></td>
		<td>Periode</td><td>:</td><td><?php echo $_sesi; ?> / <?php echo $_periode; ?></td></tr>
		<tr><td width="5%"></td>
		<td>Dosen Pengajar</td><td>:</td><td><?php echo $_data->dosen; ?></td></tr>
		<tr><td width="5%"></td>
		<td>Kuota Kelas</td><td>:</td><td>
	<?php
	if ($_data->pagu == 0) {
		echo "Jumlah mahasiswa tidak dibatasi.";
	} else {
		echo "Maksimal $pagu mahasiswa";
	}
	?>
		</td></tr>
		<tr><td width="5%"></td>
		<td>Hari</td><td>:</td><td><?php echo $_data->hari; ?></td></tr>
		<tr><td width="5%"></td>
		<td>Pukul</td><td>:</td><td><?php echo $_data->mulaipukul." - ".$_data->selesaipukul; ?> WIB</td></tr>
		</table>
		<br>
		<table width="88%" border=0>
		<tr><td width=5%></td><td>
		<table align=center width="100%" border="1">
		<tr>
		<td width="7%"><center>N R P</center></td>
		<td width="30%"><center>N A M A &nbsp; M A H A S I S W A</center></td>
		<td width="7%"><center>STATUS</td>
		<td width="15%"><center>TGL & JAM DAFTAR</td>
		</tr>
	<?php

	$sql = "SELECT registrasi.nrp, status, nama, date_format(registrasi.tanggal,'%d-%m-%Y') as tanggal, jam 
			FROM registrasi, biodata where kodemk=:kodemk and sesi=:sesi and periode=:periode 
			AND registrasi.nrp = biodata.nrp ORDER BY registrasi.tanggal ASC, registrasi.jam ASC";
	$stmt = $pdo->prepare($sql);
	$stmt->execute(array(':kodemk' => $_kodemk
							,':sesi' => $_sesi
							,':periode' => $_periode)); //reg jurusan dari protect1.php

	$jumlah_mahasiswa = 0;
	while($_data2 = $stmt->fetch(PDO::FETCH_OBJ)){ //fetch data to stdclass object		
		//list($nrp,$status,$namamhs, $tanggal, $jam) = $row;
		if (empty($_data2->nrp)) {
			echo "";
			break;
		}
		?>
			<tr><td><center><?php echo $_data2->nrp; ?></center></td>
			<td><?php echo $_data2->nama; ?></td>
			<td><center><?php echo $_data2->status; ?></td>
			<td><center><?php echo $_data2->tanggal." ".$_data2->jam; ?></center></td>
			</tr>
		<?php
		$jumlah_mahasiswa++;
	}
	?>
		</table></td><td width=5%></td></table>
		<br>
		<table width="78%" border="0">
		<tr>
		<td width="35%">Jumlah mahasiswa yang terdaftar saat ini</td><td width="1%">:</td><td><b><?php echo $jumlah_mahasiswa; ?></b> mahasiswa</td></tr>
		</table>
		<br>
		<table width="88%" border="0">
		<tr><td width="5%"></td><td colspan=6>Daftarkan mata kuliah ini ke dalam KRS saya pada</td></tr>
		<form name="frmdaftar" method="POST" action="add.php">
		<tr><td width="7%"></td><td width="19%">Semester : <?php echo $_global_settings['semester']->value; ?></td>	<!-- semesterannya diganti -->
		<td width="21%">Periode : <?php echo $_global_settings['tahun_ajaran']->value; ?></td>						<!-- tahun ajaran ato periode -->
		<input type="hidden" name="kodemk" value="<?php echo $_kodemk; ?>">
		<input type="hidden" name="sks" value="<?php echo $_data->sks; ?>">
		<!-- <input type="hidden" name="jumlah_mahasiswa" value="<?php /* echo $jumlah_mahasiswa; */ ?>"> --><!-- gk butuh rs e -->
		<input type="hidden" name="daftar_hari" value="<?php echo $_data->hari; ?>">
		<input type="hidden" name="daftar_mulaipukul" value="<?php echo $_data->mulaipukul; ?>">
		<input type="hidden" name="daftar_selesaipukul" value="<?php echo $_data->selesaipukul; ?>">
		<!-- <input type="hidden" name="recno" value="<?php /*echo $_recno; */ ?>"> -->
		<td width="5%"> <input name="Submit" type="submit" value="Daftar"></td>
		</form>
		<form name="frmbatal" method="post" action="studentpage.php">
		<td><input type="button" value="Kembali" onClick="javascript: history.go(-1)"></td></tr>
		</form>
		</table>
		<br>
	<?php
	include("footer.php");

	/*
//
	$hasil=mysql_query($sqlstr);
	$row = mysql_fetch_row($hasil);
	list($dosen,$pagu,$keterangan,$namamk,$sksx,$hari,$mulaipukul,$selesaipukul) = $row;
	echo "<BR>";
	echo "<table width=\"88%\" border=\"0\">";
	echo "<tr><td width=\"5%\"></td>";
	echo "<td width=\"15%\">" . "Kode Mata Kuliah" . "</td>" . "<td width=\"1%\">" . ":" . "</td>" . "<td>" . $kodemkx . "</td></tr>";
	echo "<tr><td width=\"5%\"></td>";
	echo "<td>" . "Nama Mata Kuliah" . "</td>" . "<td>" . ":" . "</td>" . "<td>" . $namamk . "</td></tr>";
	echo "<tr><td width=\"5%\"></td>";
	echo "<td>" . "Jumlah SKS" . "</td>" . "<td>" . ":" . "</td>" . "<td>" . $sksx . "</td></tr>";
	echo "<tr><td width=\"5%\"></td>";
	echo "<td>" . "Keterangan" . "</td>" . "<td>" . ":" . "</td>" . "<td>" . $keterangan . "</td></tr>";
	echo "<tr><td width=\"5%\"></td>";
	echo "<td>" . "Semester" . "</td>" . "<td>" . ":" . "</td>" . "<td>" . $semester . "</td></tr>";
	echo "<tr><td width=\"5%\"></td>";
	echo "<td>" . "Periode" . "</td>" . "<td>" . ":" . "</td>" . "<td>" . $sesix . " / " . $periodex . "</td></tr>";
	echo "<tr><td width=\"5%\"></td>";
	echo "<td>" . "Dosen Pengajar" . "</td>" . "<td>" . ":" . "</td>" . "<td>" . $dosen . "</td></tr>";
	echo "<tr><td width=\"5%\"></td>";
	echo "<td>" . "Kuota Kelas" . "</td>" . "<td>" . ":" . "</td>" . "<td>";
	if ($pagu == 0) {
		echo "Jumlah mahasiswa tidak dibatasi.";
	} else {
		echo "Maksimal $pagu mahasiswa";
	}
	echo "</td></tr>";
	echo "<tr><td width=\"5%\"></td>";
	echo "<td>" . "Hari" . "</td>" . "<td>" . ":" . "</td><td>"  . $hari . "</td></tr>";
	echo "<tr><td width=\"5%\"></td>";
	echo "<td>" . "Pukul" . "</td>" . "<td>" . ":" . "</td><td>"  . $mulaipukul . " - " . $selesaipukul . " WIB" . "</td></tr>";
	echo "</table>";
	echo "<br>";
    echo "<table width=\"88%\" border=0>";
	echo "<tr><td width=5%></td><td>";
	echo "<table align=center width=\"100%\" border=\"1\">";
	echo "<tr>";
	echo "<td width=\"7%\"><center>N R P</center></td>";
	echo "<td width=\"30%\"><center>N A M A &nbsp; M A H A S I S W A</center></td>";
	echo "<td width=\"7%\"><center>STATUS</td>";
	echo "<td width=\"15%\"><center>TGL & JAM DAFTAR</td>";
	echo "</tr>";

	$sqlstr="select registrasi.nrp, registrasi.status, biodata.nama, date_format(registrasi.tanggal,'%d-%m-%Y'), registrasi.jam from registrasi,biodata where kodemk='$kodemkx' and sesi='$sesix' and periode='$periodex' and registrasi.nrp=biodata.nrp order by registrasi.tanggal";
	$hasil=mysql_query($sqlstr);
	$row = mysql_fetch_row($hasil);
	$counter=0;
	do {
		list($nrp,$status,$namamhs, $tanggal, $jam) = $row;
		if (empty($nrp)) {
		echo "";
		break;
		} 
		echo "<tr><td><center> $nrp </center></td>";
		echo "<td> $namamhs </td>";
		echo "<td><center> $status </td>";
		echo "<td><center> $tanggal $jam </center></td>";
		echo "</tr>";
		$counter=$counter + 1;
	} while ($row=mysql_fetch_row($hasil));
	echo "</table></td><td width=5%></td></table>";
	echo "<br>";
	
	echo "<table width=\"78%\" border=\"0\">";
	echo "<tr>";
	echo "<td width=\"35%\">Jumlah mahasiswa yang terdaftar saat ini" . "</td>" . "<td width=\"1%\">" . ":" . "</td>" . "<td><b>" . $counter . "</b> mahasiswa" . "</td></tr>";
	echo "</table>";
	echo "<br>";
	echo "<table width=\"88%\" border=\"0\">";
	echo "<tr><td width=\"5%\"></td><td colspan=6>Daftarkan mata kuliah ini ke dalam KRS saya pada</td></tr>";
	echo "<form name=\"frmdaftar\" method=\"POST\" action=\"add.php\">";
	echo "<tr><td width=\"7%\"></td><td width=\"19%\">Semester : GASAL</td>";	// semesterannya diganti
	echo "<input name=\"sel_sesi\" value=\"GASAL\" type=\"hidden\">";		// semesterannya diganti
	echo "<td width=\"21%\">Periode : 2012-2013</td>";				// tahun ajaran ato periode
	echo "<input type=hidden name=sel_periode value=\"2012-2013\">";		// tahun ajaran ato periode
	echo "<input type=hidden name=kodemk value=" . $kodemkx . ">";
	echo "<input type=hidden name=sksx value=" . $sksx . ">";
	echo "<input type=hidden name=jmlmhs value=" . $counter . ">";
	echo "<input type=hidden name=dftr_hari value=" . $hari . ">";
	echo "<input type=hidden name=dftr_mulaipukul value=" . $mulaipukul . ">";
	echo "<input type=hidden name=dftr_selesaipukul value=" . $selesaipukul . ">";
	echo "<input type=hidden name=recno value=" . $recno . ">";
	echo "<td width=\"5%\"> " . "<input name=\"Submit\" type=\"submit\" value=\"Daftar\">" . "</td>";
	echo "</form>";
	echo "<form name=\"frmbatal\" method=\"post\" action=\"studentpage.php\">";
	echo "<td>" . "<input type=\"button\" value=\"Kembali\" onClick=\"javascript: history.go(-1)\">" . "</td></tr>";
	echo "</form>";
	echo "</table>";
	echo "<br>";

	*/
?>
	&nbsp;</td>
  </tr>
  <tr>
    <td bgcolor="7e96dc"><div align="center">
	<footer id="main">
	  <a href="http://www.widyakartika.ac.id/perpustakaan">Perpustakaan Online</a> | <a href="http://krs.widyakartika.ac.id/">KRS Online</a>
	  <br \>
	  Copyright &copy; 2012. <a href="http://www.widyakartika.ac.id">Universitas Widya Kartika</a> & <a href="#">Labkom ICT</a> - All rights reserved
	  <p>
		<?php
			$_finish_timer = get_microtime();
			echo 'Page generated in '.round(($_finish_timer - $_start_timer), 4).' seconds.';
		?>
	</footer>
	</div></td>
  </tr>
</table>

